# 6.将名片管理系统实现
cards = [
    {'name': 'je1', 'tel': '183', 'job': 'CEO'},
    {'name': 'je2', 'tel': '156', 'job': 'cdo'}
]


def card_input():
    name = input('姓名: ')
    tel = input('电话: ')
    job = input('职位: ')
    print(f'添加姓名:{name}电话:{tel}职位:{job}')


def card_see():
    card_info = input('查询的信息: ')
    for card_dict in cards:
        if card_info == card_dict['name']:
            print('\t姓名''\t电话''\t职位', end='  ')
            print(card_dict.values())
        elif card_info == card_dict['tel']:
            print('\t姓名''\t电话''\t职位', end='  ')
            print(card_dict.values())
    else:
        print('查无此人')


def alter_dict():
    print('请输入准确信息')
    card_alter = input('需要修改信息:')
    for card_dict in cards:
        if card_alter == card_dict['name']:
            card_dict['name'] = input('name: ')
            card_dict['tel'] = input('tel: ')
            card_dict['job'] = input('job: ')
            print('修改成功')
            break
    else:
        print('查无此人')


def del_dict():
    del_card = input('需要删除的name: ')
    for card_dict in cards:
        if del_card == card_dict['name']:
            cards.remove(card_dict)
            print('成功删除')
            break
    else:
        print(f'没有{del_card}')


while True:
    card = input('添加:1\t显示:2\t修改:3\t删除:4\t退出:quit :')
    if card == '1':
        card_input()
    elif card == '2':
        card_see()
    elif card == '3':
        alter_dict()
    elif card == '4':
        del_dict()
    elif card == 'quit':
        print('成功退出')
        break
    else:
        print('未知信息')

# 不会做
